package org.example.controller;

import org.example.service.IGoodsService;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;


/**
 *
 * 总页数是10页， 左右摆三页:
 *     当前页为第1页:  1  2 3 4 ... 10
 *     当前页为第4页:  1  2 3 4 5 6 7 ... 10
 *     当前页为第5页:  1 2 3 4 5 6 7 8... 10
 *     当前页为第6页:  1 ... 3 4 5 6 7 8 9 10
 *     前页为第9页:  1 ... 6 7 8 9 10
 *
 */
@RestController
@RequestMapping("/goods")
public class GoodsController {

    private IGoodsService goodsService;

    public GoodsController(IGoodsService goodsService) {
        this.goodsService = goodsService;
    }

    @GetMapping
    public Object getPageData(@RequestParam(defaultValue = "1") Integer page,
                              @RequestParam(defaultValue = "10") Integer limit) {
        return goodsService.selectPageData(page, limit);
    }
}
